import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { defHttp } from '/@/utils/http/axios';
import { rules } from '/@/utils/helper/validator';
import { render, formattingMin, formattingDay } from '/@/utils/common/renderUtils';
//列表数据
export const columns : BasicColumn[] = [
	{
		title: '订单状态',
		align: "center",
		dataIndex: 'stats',
		customRender: ({ text }) => {
			if (text == 'Waitpay') {
				return '报名待付款'
			} else if (text == 'Mark') {
				return '候选待付款'
			} else if (text == 'Join') {
				return '已入团'
			} else if (text == 'Payback') {
				return '已退款'
			} else if (text == 'Out') {
				return '已离开'
			} else if (text == 'Timeout') {
				return '超时退出'
			} else if (text == 'Finished') {
				return '已完成'
			} else if (text == 'Dispatched') {
				return '已调度'
			} else if (text == 'Payed') {
				return '已支付'
			} else if (text == 'PayFail') {
				return '付款失败'
			}else if (text == 'WaitEval') {
				return '待评价'
			}else if (text == 'WaitTravel') {
				return '待出行'
			}
			//   - 付款失败
		}
	},
	{
		title: '用户',
		align: "center",
		dataIndex: 'userid_dictText'
	},
	/* {
	 title: '旅游拼团ID',
	 align:"center",
	 dataIndex: 'travelgroupid'
	}, */
	{
		title: '付款截止时间',
		align: "center",
		dataIndex: 'payexpiretime',
		customRender: ({ text }) => {
			return formattingMin(text)
		}
	},
	{
		title: '提交报名时间',
		align: "center",
		dataIndex: 'createtime',
		customRender: ({ text }) => {
			return formattingMin(text)
		}
	},
	{
		title: '是否已签合同',
		align: "center",
		dataIndex: 'signcontract',
		customRender: ({ text }) => {
			if (text == true) {
				return '是'
			} else {
				return '否'
			}
		}
	},
	{
		title: '待付款金额，原价',
		align: "center",
		dataIndex: 'originprice'
	},
	{
		title: '减去退款后最终金额',
		align: "center",
		dataIndex: 'finalprice'
	},
	{
		title: '上车地',
		align: "center",
		dataIndex: 'upCarPoint',
		customRender: ({ text }) => {
			console.log(text)
			if (text) {
				return text.address
			}
		},
		ellipsis: true
	},
	/*   {
		title: '操作历史',
		align:"center",
		dataIndex: 'ctlhistory'
	   },
	   {
		title: '其余信息',
		align:"center",
		dataIndex: 'extinfor'
	   }, */
];
//查询数据
export const searchFormSchema : FormSchema[] = [
];

//表单数据
export const formSchema : FormSchema[] = [
	{
		label: '订单状态。',
		field: 'stats',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入订单状态。!' },
			];
		},
	},
	{
		label: '用户ID',
		field: 'userid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入用户ID!' },
			];
		},
	},
	{
		label: '旅游拼团ID',
		field: 'travelgroupid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入旅游拼团ID!' },
			];
		},
	},
	{
		label: '付款截至时间',
		field: 'payexpiretime',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入付款截至时间!' },
			];
		},
	},
	{
		label: '创建时间',
		field: 'createtime',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入创建时间!' },
			];
		},
	},
	{
		label: '是否已签合同',
		field: 'signcontract',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入是否已签合同!' },
			];
		},
	},
	{
		label: '待付款金额，原价',
		field: 'originprice',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入待付款金额，原价!' },
			];
		},
	},
	{
		label: '减去退款后最终金额',
		field: 'finalprice',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入减去退款后最终金额!' },
			];
		},
	},
	{
		label: '上车地',
		field: 'startpoint',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入上车地!' },
			];
		},
	},
	{
		label: '操作历史',
		field: 'ctlhistory',
		component: 'InputTextArea',//TODO 注意string转换问题
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入操作历史!' },
			];
		},
	},
	{
		label: '其余信息',
		field: 'extinfor',
		component: 'InputTextArea',//TODO 注意string转换问题
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入其余信息!' },
			];
		},
	},
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
];

//子表列表数据
export const bsTravelgroupTouruserinforColumns : BasicColumn[] = [
	/*   {
		title: '报名记录ID',
		align:"center",
		dataIndex: 'tourorderrecordid'
	   }, */
	{
		title: '性别',
		align: "center",
		dataIndex: 'sex',
		customRender: ({ text }) => {
			if (text == 'FeMale') {
				return '女'
			} else {
				return '男'
			}
		}
	},
	{
		title: '真实姓名',
		align: "center",
		dataIndex: 'realname'
	},
	{
		title: '电话号码',
		align: "center",
		dataIndex: 'phone'
	},
	{
		title: '身份证号',
		align: "center",
		dataIndex: 'idnum'
	},
	/*  {
	   title: '其他信息，包含了加密电话号码以及身份证号',
	   align:"center",
	   dataIndex: 'extinfor'
	  }, */
];
//子表表单数据
export const bsTravelgroupTouruserinforFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '报名记录ID',
		field: 'tourorderrecordid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入报名记录ID!' },
			];
		},
	},
	{
		label: '性别，男，女',
		field: 'sex',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入性别，男，女!' },
			];
		},
	},
	{
		label: '真实姓名',
		field: 'realname',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入真实姓名!' },
			];
		},
	},
	{
		label: '电话号码，脱敏',
		field: 'phone',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入电话号码，脱敏!' },
			];
		},
	},
	{
		label: '身份证号，脱敏',
		field: 'idnum',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入身份证号，脱敏!' },
			];
		},
	},
	{
		label: '其他信息，包含了加密电话号码以及身份证号',
		field: 'extinfor',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入其他信息，包含了加密电话号码以及身份证号!' },
			];
		},
	},
];
//子表列表数据
export const bsTravelgroupTourcarpricerecordColumns : BasicColumn[] = [
	{
		title: '用户',
		align: "center",
		dataIndex: 'userid_dictText'
	},
	/*   {
		title: '报名记录',
		align:"center",
		dataIndex: 'tourorderrecordid'
	   }, */
	{
		title: '自选报名车辆费用',
		align: "center",
		dataIndex: 'pretravelcarid'
	},
	{
		title: '报名时间',
		align: "center",
		dataIndex: 'createtime',
		customRender: ({ text }) => {
			return formattingMin(text)
		}
	},
	{
		title: '原价',
		align: "center",
		dataIndex: 'originprice'
	},
	{
		title: '最终价格',
		align: "center",
		dataIndex: 'finalprice'
	},
	/*   {
		title: '其他信息',
		align:"center",
		dataIndex: 'extinfor'
	   }, */
];
//子表表单数据
export const bsTravelgroupTourcarpricerecordFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '用户ID',
		field: 'userid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入用户ID!' },
			];
		},
	},
	{
		label: '报名记录',
		field: 'tourorderrecordid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入报名记录!' },
			];
		},
	},
	{
		label: '自选报名车辆费用',
		field: 'pretravelcarid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入自选报名车辆费用!' },
			];
		},
	},
	{
		label: '创建时间',
		field: 'createtime',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入创建时间!' },
			];
		},
	},
	{
		label: '原价',
		field: 'originprice',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入原价!' },
			];
		},
	},
	{
		label: '最终价格，扣除差价后的',
		field: 'finalprice',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入最终价格，扣除差价后的!' },
			];
		},
	},
	{
		label: '其他信息',
		field: 'extinfor',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入其他信息!' },
			];
		},
	},
];
//子表列表数据
export const bsTravelgroupTourordershopproductrecordColumns : BasicColumn[] = [
	{
		title: '状态',//。WaitOff：待核销；Finished：已核销；Backoff：已退款；Cancel：取消
		align: "center",
		dataIndex: 'stats',
		customRender: ({ text }) => {
			if (text == 'WaitOff') {
				return '待核销'
			} else if (text == 'Finished') {
				return '已核销'
			} else if (text == 'Backoff') {
				return '已退款'
			} else if (text == 'Cancel') {
				return '已取消'
			}
		}
	},
/* 	{
		title: '用户',
		align: "center",
		dataIndex: 'userid'
	},
	  {
		title: '报名记录ID',
		align:"center",
		dataIndex: 'tourorderrecordid'
	   }, */
	{
		title: '商品ID',
		align: "center",
		dataIndex: 'shopproductid_dictText'
	},
	{
		title: '核销员ID',
		align: "center",
		dataIndex: 'writeoffuserid_dictText'
	},
	/* 	{
			title: '创建时间',
			align: "center",
			dataIndex: 'createtime',
			customRender: ({ text }) => {
				return formattingMin(text)
			}
		}, */
	{
		title: '原始金额',
		align: "center",
		dataIndex: 'originprice'
	},
	{
		title: '核销时间',
		align: "center",
		dataIndex: 'writeofftime',
		customRender: ({ text }) => {
			return formattingMin(text)
		}
	},
	/* 	{
			title: '其他信息，json格式',
			align: "center",
			dataIndex: 'extinfor'
		}, */
];
//子表表单数据
export const bsTravelgroupTourordershopproductrecordFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '状态',
		field: 'stats',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入状态!' },
			];
		},
	},
	{
		label: '用户ID',
		field: 'userid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入用户ID!' },
			];
		},
	},
	{
		label: '报名记录ID',
		field: 'tourorderrecordid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入报名记录ID!' },
			];
		},
	},
	{
		label: '商品ID',
		field: 'shopproductid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入商品ID!' },
			];
		},
	},
	{
		label: '核销员ID',
		field: 'writeoffuserid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入核销员ID!' },
			];
		},
	},
	{
		label: '创建时间',
		field: 'createtime',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入创建时间!' },
			];
		},
	},
	{
		label: '原始金额',
		field: 'originprice',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入原始金额!' },
			];
		},
	},
	{
		label: '核销时间',
		field: 'writeofftime',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入核销时间!' },
			];
		},
	},
	{
		label: '其他信息，json格式',
		field: 'extinfor',
		component: 'InputTextArea',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入其他信息，json格式!' },
			];
		},
	},
];
//子表列表数据
export const bsTravelgroupTourorderhotelroomrecordColumns : BasicColumn[] = [
/* 	{
		title: '用户ID',
		align: "center",
		dataIndex: 'userid'
	}, */
/* 	{
		title: '报名记录',
		align: "center",
		dataIndex: 'tourorderrecordid'
	}, */
	{
		title: '酒店房间费用',
		align: "center",
		dataIndex: 'hotelroompriceid_dictText'
	},
	/* {
		title: 'createtime',
		align: "center",
		dataIndex: 'createtime'
	}, */
	{
		title: '原始费用',
		align: "center",
		dataIndex: 'originprice'
	},
];
//子表表单数据
export const bsTravelgroupTourorderhotelroomrecordFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '用户ID',
		field: 'userid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入用户ID!' },
			];
		},
	},
	{
		label: '报名记录',
		field: 'tourorderrecordid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入报名记录!' },
			];
		},
	},
	{
		label: '酒店房间费用ID',
		field: 'hotelroompriceid',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入酒店房间费用ID!' },
			];
		},
	},
	{
		label: 'createtime',
		field: 'createtime',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入createtime!' },
			];
		},
	},
	{
		label: '原始费用',
		field: 'originprice',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入原始费用!' },
			];
		},
	},
];